/*
*	Copyright (C) 2014  Julio Montes, Mario Carrillo
*	
*	Julio Montes e-mail: imc.coder@gmail.com 
*
*	Mario Carrillo e-mail: mario_90ago@live.com.mx
*
*	BSD 3-Clause License
*/

#ifndef ALLIANCE_LOGMGR_H
#define ALLIANCE_LOGMGR_H

#include "sdk/include/mgr.h"

#include <wx/wx.h>
#include <wx/notebook.h>
#include <wx/aui/aui.h>

#ifdef USE_RICHTEXTCTRL
#include <wx/richtext/richtextctrl.h>
#endif // USE_RICHTEXTCTRL

#include "alliance/include/tool.h"

namespace alliance
{
    class Project;
    class NotebookLogProject;

    class LogManager : public sdk::Mgr<LogManager>
    {
        friend class sdk::Mgr<LogManager>;
    public:
        enum ImageStatus
        {
            SUCCESS_IMG,
            WARNING_IMG,
            ERROR_IMG
        };

        bool OnClose();
        bool Load();
        void ClearLogProject( Project *project );
        void ShowLog( Project *project, const Tool &tool, ImageStatus status, const wxString &stdinStr, const wxString &stderrStr );
    protected:
    private:
        LogManager();
        virtual ~LogManager();

        NotebookLogProject *GetLogProject( Project *project ) const;

        wxAuiNotebook *m_notebook;
    };

    class LogTool :
#ifdef USE_RICHTEXTCTRL
    public wxRichTextCtrl
#else
    public wxTextCtrl
#endif // USE_RICHTEXTCTRL
    {
    public:
        LogTool( wxWindow *parent );
        virtual ~LogTool();

        void SetLog( const Tool &tool, const wxString &stdinStr, const wxString &stderrStr );
    protected:
    private:
    };

    class NotebookLogProject : public wxNotebook
    {
    public:
        NotebookLogProject( wxWindow *parent, const wxString &id );
        virtual ~NotebookLogProject();

        const wxString &GetId() const;

        void AddLog( const Tool &tool, LogManager::ImageStatus status, const wxString &stdinStr, const wxString &stderrStr );
    protected:
    private:
        const wxString m_id;
    };
}

#endif //ALLIANCE_LOGMGR_H
